//
//  MyTabbarController.swift
//  SWfanghu
//
//  Created by 李言 on 16/6/6.
//  Copyright © 2016年 ly. All rights reserved.
//

import UIKit

class MyViewController: BaseviewController {
    var aa:String!
    private lazy var topView: UIView! = {[unowned self] in
        let view = UIView(frame: CADipRectMake(0, self.navbarHeight, self.frameSize.width, 280))
        view.backgroundColor = color_import_red
        return view
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        // 这个是必要的设置
        automaticallyAdjustsScrollViewInsets = false

        navigationController?.navigationBar.hidden = false

        var style = SegmentStyle()
        // 滚动条
        style.showLine = true
        // 滚动条颜色
        style.scrollLineColor = color_import_red
        let titles = setChildVcs().map { $0.title! }

        // topView
        view.addSubview(topView)

        let scroll = ScrollPageView(frame: CGRect(x: 0, y: topView.frame.maxY, width: view.bounds.size.width, height: view.bounds.size.height - topView.frame.maxY - (tabBarController?.tabBar.frame.height)!), segmentStyle: style, titles: titles, childVcs: setChildVcs(), parentViewController: self)
        view.addSubview(scroll)
        
        let nav = UINavigationController(rootViewController: LoginController())
        presentViewController(nav, animated: true, completion: nil)
    }

    func setChildVcs() -> [UITableViewController] {

        let vc1 = MyOrderListController()
        vc1.title = "所有订单"

        let vc2 = MyAlreadyCommentController()
        vc2.title = "已评房"

        let vc3 = MyAlreadyFailureTableViewController()
        vc3.title = "已失败"
        
        return [vc1, vc2, vc3]
    }
}
